package zhengqc.sort;

public class ShellSort <E extends Comparable<E>> extends Sort<E> {
    public ShellSort() { this.sortName = "ShellSort"; }
    @Override
    public void sort(E[] array) {
        int h = array.length / 2;
        while ( h >= 1) {
            for (int i = h; i < array.length; ++i) {
                E t = array[i];
                int j = i;
                while (j >= h && t.compareTo(array[j-1]) < 0) {
                    array[j] = array[j-1];
                    -- j;
                }
                array[j] = t;
            }
            h /= 2;
        }
    }
}
